
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>异常处理 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sidebar-style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="线程.html" />
    
    
    <link rel="prev" href="集合.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">基础篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="IO流基础.html">
            
                <a href="IO流基础.html">
            
                    
                    IO流基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="集合.html">
            
                <a href="集合.html">
            
                    
                    集合
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.3" data-path="异常处理.html">
            
                <a href="异常处理.html">
            
                    
                    异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="线程.html">
            
                <a href="线程.html">
            
                    
                    线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="网络编程.html">
            
                <a href="网络编程.html">
            
                    
                    网络编程
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">进阶篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../java进阶/MySQL.html">
            
                <a href="../java进阶/MySQL.html">
            
                    
                    MySQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../java进阶/Oracle.html">
            
                <a href="../java进阶/Oracle.html">
            
                    
                    Oracle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../java进阶/Redis.html">
            
                <a href="../java进阶/Redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../java进阶/Netty.html">
            
                <a href="../java进阶/Netty.html">
            
                    
                    Netty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../java进阶/Spring.html">
            
                <a href="../java进阶/Spring.html">
            
                    
                    Spring
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../java进阶/SpringMVC.html">
            
                <a href="../java进阶/SpringMVC.html">
            
                    
                    SpringMVC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../java进阶/单元测试.html">
            
                <a href="../java进阶/单元测试.html">
            
                    
                    SpringBoot单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../java进阶/设计模式.html">
            
                <a href="../java进阶/设计模式.html">
            
                    
                    二十三个设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.8.1" data-path="../java进阶/工厂模式.html">
            
                <a href="../java进阶/工厂模式.html">
            
                    
                    工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.2" data-path="../java进阶/单例模式.html">
            
                <a href="../java进阶/单例模式.html">
            
                    
                    单例模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.3" data-path="../java进阶/建造者模式.html">
            
                <a href="../java进阶/建造者模式.html">
            
                    
                    建造者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.4" data-path="../java进阶/原型模式.html">
            
                <a href="../java进阶/原型模式.html">
            
                    
                    原型模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.5" data-path="../java进阶/适配器模式.html">
            
                <a href="../java进阶/适配器模式.html">
            
                    
                    适配器模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.6" data-path="../java进阶/责任链模式.html">
            
                <a href="../java进阶/责任链模式.html">
            
                    
                    责任链模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.7" data-path="../java进阶/桥接模式.html">
            
                <a href="../java进阶/桥接模式.html">
            
                    
                    桥接模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">高级篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../springcloud/1.cloud架构选型.html">
            
                <a href="../springcloud/1.cloud架构选型.html">
            
                    
                    Spring Cloud
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../springcloud/2.Provider-支付模块.html">
            
                <a href="../springcloud/2.Provider-支付模块.html">
            
                    
                    Provider-支付模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../springcloud/3.Consumer-订单模块.html">
            
                <a href="../springcloud/3.Consumer-订单模块.html">
            
                    
                    Consumer-订单模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="../springcloud/4.重构-Common模块.html">
            
                <a href="../springcloud/4.重构-Common模块.html">
            
                    
                    重构-Common模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="../springcloud/5.注册中心-Enreka.html">
            
                <a href="../springcloud/5.注册中心-Enreka.html">
            
                    
                    注册中心-Enreka
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="../springcloud/6.负载均衡-@LoadBalance.html">
            
                <a href="../springcloud/6.负载均衡-@LoadBalance.html">
            
                    
                    负载均衡-@LoadBalance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.6" data-path="../springcloud/7.更换注册中心-Zookeeper.html">
            
                <a href="../springcloud/7.更换注册中心-Zookeeper.html">
            
                    
                    更换注册中心-Zookeeper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.7" data-path="../springcloud/8.更换注册中心-Consul.html">
            
                <a href="../springcloud/8.更换注册中心-Consul.html">
            
                    
                    更换注册中心-Consul
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.8" data-path="../springcloud/9.负载均衡-Ribbon.html">
            
                <a href="../springcloud/9.负载均衡-Ribbon.html">
            
                    
                    负载均衡-Ribbon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.9" data-path="../springcloud/10.服务调用-OpenFeign.html">
            
                <a href="../springcloud/10.服务调用-OpenFeign.html">
            
                    
                    服务调用-OpenFeign
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.10" data-path="../springcloud/11.熔断器-Hystrix.html">
            
                <a href="../springcloud/11.熔断器-Hystrix.html">
            
                    
                    熔断器-Hystrix
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.11" data-path="../springcloud/12.网关-Gateway.html">
            
                <a href="../springcloud/12.网关-Gateway.html">
            
                    
                    网关-Gateway
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.12" data-path="../springcloud/13.配置中心-Config.html">
            
                <a href="../springcloud/13.配置中心-Config.html">
            
                    
                    配置中心-Config
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.13" data-path="../springcloud/14.消息总线-bus.html">
            
                <a href="../springcloud/14.消息总线-bus.html">
            
                    
                    消息总线-Bus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.14" data-path="../springcloud/15.消息驱动-stream.html">
            
                <a href="../springcloud/15.消息驱动-stream.html">
            
                    
                    消息驱动-Stream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.15" data-path="../springcloud/16.链路监控-Sleuth.html">
            
                <a href="../springcloud/16.链路监控-Sleuth.html">
            
                    
                    链路监控-Sleuth
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.16" data-path="../springcloud/17.注册中心&配置中心-nacos.html">
            
                <a href="../springcloud/17.注册中心&配置中心-nacos.html">
            
                    
                    注册中心&配置中心-nacos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.17" data-path="../springcloud/18.限流-sentinel.html">
            
                <a href="../springcloud/18.限流-sentinel.html">
            
                    
                    限流-sentinel
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../java高级/JUC.html">
            
                <a href="../java高级/JUC.html">
            
                    
                    神秘的JUC包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../java高级/Docker.html">
            
                <a href="../java高级/Docker.html">
            
                    
                    Docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../java高级/布隆过滤器.html">
            
                <a href="../java高级/布隆过滤器.html">
            
                    
                    布隆过滤器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../java高级/Redission.html">
            
                <a href="../java高级/Redission.html">
            
                    
                    Redission
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../java高级/MQ.html">
            
                <a href="../java高级/MQ.html">
            
                    
                    消息队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="../java高级/JVM.html">
            
                <a href="../java高级/JVM.html">
            
                    
                    JVM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="../java书籍/《Effective Java》读书笔记.html">
            
                <a href="../java书籍/《Effective Java》读书笔记.html">
            
                    
                    《Effective Java》读书笔记 
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.8.1" data-path="../java书籍/创建和销毁对象.html">
            
                <a href="../java书籍/创建和销毁对象.html">
            
                    
                    创建和销毁对象
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">番外篇</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../java面试/面试题.html">
            
                <a href="../java面试/面试题.html">
            
                    
                    面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../番外篇/小程序.html">
            
                <a href="../番外篇/小程序.html">
            
                    
                    微信小程序
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >异常处理</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <p><strong>&#x5F02;&#x5E38;</strong>&#x6307;&#x7684;&#x662F;&#x7A0B;&#x5E8F;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#xFF08;&#x4E0D;&#x662F;&#x7F16;&#x8BD1;&#x65F6;&#x671F;&#xFF09;&#x53D1;&#x751F;&#x7684;&#x975E;&#x6B63;&#x5E38;&#x7684;&#x60C5;&#x51B5;&#x6216;&#x8005;&#x9519;&#x8BEF;&#xFF0C;&#x5F53;&#x7A0B;&#x5E8F;&#x8FDD;&#x53CD;&#x4E86;&#x8BED;&#x4E49;&#x89C4;&#x5219;&#x65F6;&#xFF0C;JVM&#x5C31;&#x4F1A;&#x5C06;&#x51FA;&#x73B0;&#x7684;&#x9519;&#x8BEF;&#x8868;&#x793A;&#x4E3A;&#x4E00;&#x4E2A;&#x5F02;&#x5E38;&#x5E76;&#x629B;&#x51FA;&#x3002;&#x8FD9;&#x4E2A;&#x5F02;&#x5E38;&#x53EF;&#x4EE5;&#x5728;catch&#x7A0B;&#x5E8F;&#x5757;&#x4E2D;&#x8FDB;&#x884C;&#x6355;&#x6349;&#xFF0C;&#x7136;&#x540E;&#x5904;&#x7406;&#x3002;&#x800C;&#x5F02;&#x5E38;&#x5904;&#x7406;&#x7684;&#x76EE;&#x7684;&#x5C31;&#x662F;&#x63D0;&#x9AD8;&#x7A0B;&#x5E8F;&#x7684;&#x5B89;&#x5168;&#x6027;&#x548C;&#x5065;&#x58EE;&#x6027;&#x3002;</p>
<h3 id="&#x4E00;&#x3001;&#x5F02;&#x5E38;&#x4F53;&#x7CFB;"><a name="&#x4E00;&#x3001;&#x5F02;&#x5E38;&#x4F53;&#x7CFB;" class="plugin-anchor" href="#&#x4E00;&#x3001;&#x5F02;&#x5E38;&#x4F53;&#x7CFB;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E00;&#x3001;&#x5F02;&#x5E38;&#x4F53;&#x7CFB;</h3>
<p><img src="https://tva1.sinaimg.cn/large/008eGmZEly1go8rsiqo6rj30is0ewt8o.jpg" alt="&#x5F02;&#x5E38;&#x4F53;&#x7CFB;"></p>
<h3 id="&#x4E8C;&#x3001;&#x5F02;&#x5E38;&#x5206;&#x7C7B;"><a name="&#x4E8C;&#x3001;&#x5F02;&#x5E38;&#x5206;&#x7C7B;" class="plugin-anchor" href="#&#x4E8C;&#x3001;&#x5F02;&#x5E38;&#x5206;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E8C;&#x3001;&#x5F02;&#x5E38;&#x5206;&#x7C7B;</h3>
<ol>
<li><h4 id="error"><a name="error" class="plugin-anchor" href="#error"><i class="fa fa-link" aria-hidden="true"></i></a>Error</h4>
<p>&#x8868;&#x793A;&#x7A0B;&#x5E8F;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x671F;&#x51FA;&#x73B0;&#x4E86;&#x975E;&#x5E38;&#x4E25;&#x91CD;&#x7684;&#x9519;&#x8BEF;&#xFF0C;&#x5E76;&#x4E14;&#x8BE5;&#x9519;&#x8BEF;&#x662F;&#x4E0D;&#x80FD;&#x6062;&#x590D;&#x7684;&#x3002;&#x7531;&#x4E8E;&#x8FD9;&#x5C5E;&#x4E8E;JVM&#x5C42;&#x6B21;&#x7684;&#x9519;&#x8BEF;&#xFF0C;&#x6240;&#x4EE5;&#x8FD9;&#x79CD;&#x9519;&#x8BEF;&#x4F1A;&#x5BFC;&#x81F4;&#x7A0B;&#x5E8F;&#x7EC8;&#x6B62;&#x3002;&#x6B64;&#x5916;&#xFF0C;&#x7F16;&#x8BD1;&#x5668;&#x4E0D;&#x4F1A;&#x68C0;&#x67E5;Error&#x662F;&#x5426;&#x88AB;&#x5904;&#x7406;&#x3002;</p>
<p>&#x56E0;&#x6B64;&#xFF0C;&#x5728;&#x7A0B;&#x5E8F;&#x4E2D;&#x4E0D;&#x63A8;&#x8350;&#x6355;&#x83B7;Error&#x7C7B;&#x578B;&#x5F02;&#x5E38;&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x4E00;&#x4E2A;&#x6B63;&#x5E38;&#x7684;&#x7A0B;&#x5E8F;&#x4E0D;&#x5E94;&#x8BE5;&#x5B58;&#x5728;Error&#x7684;&#x3002;OutOfMemoryError&#x3001;ThreadDeath&#x90FD;&#x5C5E;&#x4E8E;&#x9519;&#x8BEF;&#x3002;&#x5F53;&#x8FD9;&#x4E9B;&#x9519;&#x8BEF;&#x53D1;&#x751F;&#x65F6;&#xFF0C;JVM&#x4E00;&#x822C;&#x4F1A;&#x9009;&#x62E9;&#x5C06;&#x7EBF;&#x7A0B;&#x7EC8;&#x6B62;&#x3002;</p>
</li>
<li><h4 id="exception"><a name="exception" class="plugin-anchor" href="#exception"><i class="fa fa-link" aria-hidden="true"></i></a>Exception</h4>
<p>&#x8868;&#x793A;&#x53EF;&#x4EE5;&#x6062;&#x590D;&#x7684;&#x5F02;&#x5E38;&#xFF0C;&#x662F;&#x7F16;&#x8BD1;&#x5668;&#x53EF;&#x4EE5;&#x6355;&#x6349;&#x5230;&#x7684;&#x3002;&#x5B83;&#x5305;&#x542B;&#x4E24;&#x79CD;&#x7C7B;&#x578B;&#xFF0C;&#x8FD0;&#x884C;&#x65F6;&#x5F02;&#x5E38;&#xFF08;<strong>Runtime Exception</strong>&#xFF09;&#x548C;&#x68C0;&#x67E5;&#x5F02;&#x5E38;&#xFF08;<strong>Checked Exception</strong>&#xFF09;&#x3002;</p>
<ul>
<li><h5 id="checked-exception"><a name="checked-exception" class="plugin-anchor" href="#checked-exception"><i class="fa fa-link" aria-hidden="true"></i></a>Checked Exception</h5>
<p>&#x68C0;&#x67E5;&#x5F02;&#x5E38;&#x662F;&#x7A0B;&#x5E8F;&#x4E2D;&#x6700;&#x7ECF;&#x5E38;&#x78B0;&#x5230;&#x7684;&#x5F02;&#x5E38;&#xFF0C;&#x6240;&#x6709;&#x7EE7;&#x627F;&#x81EA;Exception &#x4E0D;&#x662F;&#x8FD0;&#x884C;&#x5F02;&#x5E38;&#x7684;&#x5F02;&#x5E38;&#x90FD;&#x662F;&#x68C0;&#x67E5;&#x5F02;&#x5E38;&#xFF0C;&#x6BD4;&#x5982;<strong>IO</strong>&#x5F02;&#x5E38;&#x548C;<strong>SQL</strong>&#x5F02;&#x5E38;&#x3002;&#x5BF9;&#x4E8E;&#x8FD9;&#x4E9B;&#x5F02;&#x5E38;&#xFF0C;&#x90FD;&#x53D1;&#x751F;&#x5728;&#x7F16;&#x8BD1;&#x9636;&#x6BB5;&#xFF0C;java&#x7F16;&#x8BD1;&#x5668;&#x5F3A;&#x5236;&#x7A0B;&#x5E8F;&#x53BB;&#x6355;&#x6349;&#x6B64;&#x7C7B;&#x578B;&#x7684;&#x5F02;&#x5E38;&#xFF0C;&#x5373;&#x628A;&#x53EF;&#x80FD;&#x4F1A;&#x51FA;&#x73B0;&#x8FD9;&#x4E9B;&#x5F02;&#x5E38;&#x7684;&#x4EE3;&#x7801;&#x653E;&#x5230;Try&#x5757;&#x4E2D;&#xFF0C;&#x5427;&#x5BF9;&#x5F02;&#x5E38;&#x7684;&#x5904;&#x7406;&#x653E;&#x5230;catch&#x5757;&#x4E2D;&#x3002;</p>
<ul>
<li>&#x5F02;&#x5E38;&#x7684;&#x53D1;&#x751F;&#x5E76;&#x4E0D;&#x4F1A;&#x5BFC;&#x81F4;&#x7A0B;&#x5E8F;&#x51FA;&#x9519;&#xFF0C;&#x8FDB;&#x884C;&#x5904;&#x7406;&#x540E;&#x53EF;&#x4EE5;&#x7EE7;&#x7EED;&#x6267;&#x884C;&#x540E;&#x7EED;&#x7684;&#x64CD;&#x4F5C;&#x3002;&#x4F8B;&#x5982;&#xFF1A;&#x5F53;&#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;&#x5931;&#x8D25;&#x540E;&#xFF0C;&#x53EF;&#x4EE5;&#x91CD;&#x65B0;&#x8FDE;&#x63A5;&#x540E;&#x8FDB;&#x884C;&#x540E;&#x7EED;&#x64CD;&#x4F5C;&#x3002;</li>
<li>&#x7A0B;&#x5E8F;&#x4F9D;&#x8D56;&#x4E8E;&#x4E0D;&#x53EF;&#x9760;&#x7684;&#x5916;&#x90E8;&#x6761;&#x4EF6;&#x3002;&#x4F8B;&#x5982;&#xFF1A;&#x7CFB;&#x7EDF;IO&#x3002;</li>
</ul>
</li>
<li><h5 id="runtime-exception"><a name="runtime-exception" class="plugin-anchor" href="#runtime-exception"><i class="fa fa-link" aria-hidden="true"></i></a>Runtime Exception</h5>
<p>&#x7F16;&#x8BD1;&#x5668;&#x6CA1;&#x6709;&#x5F3A;&#x5236;&#x5BF9;&#x5176;&#x8FDB;&#x884C;&#x6355;&#x83B7;&#x5E76;&#x5904;&#x7406;&#x3002;&#x5982;&#x679C;&#x4E0D;&#x5BF9;&#x8FD9;&#x79CD;&#x5F02;&#x5E38;&#x8FDB;&#x884C;&#x5904;&#x7406;&#xFF0C;&#x5F53;&#x51FA;&#x73B0;&#x4E86;&#x8FD9;&#x79CD;&#x5F02;&#x5E38;&#x65F6;&#xFF0C;&#x4F1A;&#x6709;JVM&#x6765;&#x5904;&#x7406;&#x3002;&#x5728;JAVA&#x8BED;&#x8A00;&#x4E2D;&#xFF0C;&#x6700;&#x5E38;&#x89C1;&#x7684;&#x8FD0;&#x884C;&#x65F6;&#x5F02;&#x5E38;&#x6709;&#xFF1A;NullPointerExcepton&#xFF08;&#x7A7A;&#x6307;&#x9488;&#x5F02;&#x5E38;&#xFF09;&#x3001;ArraysStoreException&#xFF08;&#x6570;&#x7EC4;&#x5B58;&#x50A8;&#x5F02;&#x5E38;&#xFF09;&#x3001;ClassCastException&#xFF08;&#x7C7B;&#x8F6C;&#x6362;&#x5F02;&#x5E38;&#xFF09;&#x3001;IndexOutOfBoundException&#xFF08;&#x6570;&#x7EC4;&#x8D8A;&#x754C;&#x5F02;&#x5E38;&#xFF09;&#x3001;BufferOverflowException&#xFF08;&#x7F13;&#x51B2;&#x533A;&#x6EA2;&#x51FA;&#x5F02;&#x5E38;&#xFF09;&#x4EE5;&#x53CA;ArithmeticException&#xFF08;&#x7B97;&#x6570;&#x5F02;&#x5E38;&#xFF09;&#x7B49;&#x3002;</p>
<p>&#x51FA;&#x73B0;&#x8FD0;&#x884C;&#x65F6;&#x5F02;&#x5E38;&#x540E;&#xFF0C;&#x7CFB;&#x7EDF;&#x4F1A;&#x4E00;&#x76F4;&#x5F80;&#x4E0A;&#x5C42;&#x629B;&#x51FA;&#xFF0C;&#x76F4;&#x5230;&#x51FA;&#x73B0;&#x5904;&#x7406;&#x4EE3;&#x7801;&#x4E3A;&#x6B62;&#x3002;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x5904;&#x7406;&#x4EE3;&#x7801;&#x5757;&#xFF0C;&#x5219;&#x629B;&#x5230;&#x6700;&#x4E0A;&#x5C42;&#xFF0C;&#x5982;&#x679C;&#x591A;&#x7EBF;&#x7A0B;&#x5C31;&#x7531;Thread.run()&#x65B9;&#x6CD5;&#x629B;&#x51FA;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x5355;&#x7EBF;&#x7A0B;&#xFF0C;&#x5C31;&#x88AB;main()&#x65B9;&#x6CD5;&#x629B;&#x51FA;&#x3002;&#x629B;&#x51FA;&#x540E;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x7EBF;&#x7A0B;&#xFF0C;&#x5219;&#x7EBF;&#x7A0B;&#x5C31;&#x9000;&#x51FA;&#x4E86;&#x3002;&#x5982;&#x679C;&#x662F;&#x4E3B;&#x7A0B;&#x5E8F;&#x629B;&#x51FA;&#x7684;&#x5F02;&#x5E38;&#xFF0C;&#x90A3;&#x4E48;&#x6574;&#x4E2A;&#x7A0B;&#x5E8F;&#x5C31;&#x7EC8;&#x6B62;&#x4E86;&#x3002;&#x6240;&#x4EE5;&#x8BF4;&#x4E0D;&#x5BF9;&#x5F02;&#x5E38;&#x8FDB;&#x884C;&#x5904;&#x7406;&#x540E;&#x679C;&#x975E;&#x5E38;&#x4E25;&#x91CD;&#xFF0C;&#x8981;&#x4E0D;&#x7EBF;&#x7A0B;&#x7EC8;&#x6B62;&#x4E86;&#xFF0C;&#x8981;&#x4E0D;&#x4E3B;&#x7A0B;&#x5E8F;&#x7EC8;&#x6B62;&#x4E86;&#x3002;</p>
</li>
</ul>
</li>
</ol>
<h4 id="&#x4E09;&#x3001;throw&#x5F02;&#x5E38;&#x4E0E;&#x4E8B;&#x52A1;&#x5904;&#x7406;"><a name="&#x4E09;&#x3001;throw&#x5F02;&#x5E38;&#x4E0E;&#x4E8B;&#x52A1;&#x5904;&#x7406;" class="plugin-anchor" href="#&#x4E09;&#x3001;throw&#x5F02;&#x5E38;&#x4E0E;&#x4E8B;&#x52A1;&#x5904;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E09;&#x3001;throw&#x5F02;&#x5E38;&#x4E0E;&#x4E8B;&#x52A1;&#x5904;&#x7406;</h4>
<ol>
<li><h5 id="&#x60C5;&#x5F62;"><a name="&#x60C5;&#x5F62;" class="plugin-anchor" href="#&#x60C5;&#x5F62;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x60C5;&#x5F62;</h5>
<pre><code class="lang-java"><span class="hljs-meta">@Transactional</span>(rollbackFor=Exception.class)
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">method</span> <span class="hljs-params">()</span></span>{

    <span class="hljs-comment">//&#x4F1A;&#x56DE;&#x6EDA;</span>
    <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Exception(<span class="hljs-string">&quot;XXXX&quot;</span>);

    <span class="hljs-comment">//&#x4F1A;&#x56DE;&#x6EDA;</span>
    <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> RuntimeException(<span class="hljs-string">&quot;XXXX&quot;</span>);
}
</code></pre>
</li>
<li><h5 id="&#x539F;&#x56E0;&#x3002;"><a name="&#x539F;&#x56E0;&#x3002;" class="plugin-anchor" href="#&#x539F;&#x56E0;&#x3002;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x539F;&#x56E0;&#x3002;</h5>
<p>rollbackFor &#x9ED8;&#x8BA4;&#x662F; RuntimeException</p>
<pre><code class="lang-java"><span class="hljs-meta">@Transactional</span>(rollbackFor=RuntimeException.class) <span class="hljs-comment">//&#x6216;&#x8005; @Transaction() </span>
<span class="hljs-function"><span class="hljs-keyword">public</span>  <span class="hljs-keyword">void</span>  <span class="hljs-title">method</span><span class="hljs-params">()</span></span>{

    <span class="hljs-comment">//&#x4E0D;&#x4F1A;&#x56DE;&#x6EDA;</span>
    <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Exception(<span class="hljs-string">&quot;XXXX&quot;</span>);

    <span class="hljs-comment">//&#x4F1A;&#x56DE;&#x6EDA;</span>
    <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> RuntimeException(<span class="hljs-string">&quot;XXXX&quot;</span>);
}
</code></pre>
</li>
</ol>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; mine 2022-2025 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2022-06-23 10:56:38
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="集合.html" class="navigation navigation-prev " aria-label="Previous page: 集合">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="线程.html" class="navigation navigation-next " aria-label="Next page: 线程">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"异常处理","level":"2.3","depth":1,"next":{"title":"线程","level":"2.4","depth":1,"path":"java基础/线程.md","ref":"java基础/线程.md","articles":[]},"previous":{"title":"集合","level":"2.2","depth":1,"path":"java基础/集合.md","ref":"java基础/集合.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["back-to-top-button","code","splitter","expandable-chapters-small","anchors","theme-comscore","tbfed-pagefooter","sidebar-style","pageview-count","popup"],"pluginsConfig":{"sidebar-style":{"author":"梁兴龙","title":"《Java 笔记本》"},"tbfed-pagefooter":{"copyright":"Copyright &copy mine 2022-2025","modify_label":"文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"splitter":{},"search":{},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"back-to-top-button":{},"pageview-count":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"java基础/异常处理.md","mtime":"2022-06-23T02:56:38.561Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-08-22T03:22:22.085Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sidebar-style/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

